package com.wangyb.wework.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.wangyb.wework.entity.employee.EmployeeBO;
import com.wangyb.wework.entity.employee.EmployeeQueryBO;
import com.wangyb.wework.service.IWwEmployeeService;
import com.wangyb.wework.sync.WwEmployeeServiceSyncLogic;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 企业通讯录Controller
 *
 * @Author: wangyb
 * @Date: 2021/6/29 2:17 下午
 */
@Api(value = "企业通讯录控制器", tags = {"企业通讯录管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/wework/employee")
public class WwEmployeeController extends BaseController {
	@Autowired
	private  IWwEmployeeService iWwEmployeeService;
	@Autowired
	private WwEmployeeServiceSyncLogic wwEmployeeServiceSyncLogic;

	/**
	 * 查询企业通讯录列表
	 */
	@ApiOperation("查询企业通讯录列表")
	@PreAuthorize("@ss.hasPermi('wework:employee:index')")
	@GetMapping("/list")
	public TableDataInfo<EmployeeBO> list(@Validated EmployeeQueryBO bo) {
		return iWwEmployeeService.index(bo);
	}
	/**
	 * 成员 - 同步企业成员
	 */
	@PutMapping("/syncEmployee")
	public AjaxResult syncEmployee() {
		Long corpId = 1L;
		wwEmployeeServiceSyncLogic.onSyncWxEmp(corpId);
		return AjaxResult.success();
	}
}
